package com.zit.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.zit.dao.upTermDAO;
import com.zit.entity.Term;
import com.zit.util.SystemUtil;

public  class UPTermDAOImpl implements upTermDAO{
	
	private Connection con = null;
	private PreparedStatement ps = null;
	private ResultSet rs = null;
	private SystemUtil su = new SystemUtil();

	public void addTerm(Term t) {
		
		String sql = "insert into term(id,name,createTime,isDelete,remark) values(?,?,?,?,?)";
	//	con = util.getConnect();
		try {
			ps = con.prepareStatement(sql);
			ps.setInt(1, t.getId());
			ps.setString(2, t.getName());
			
			ps.setDate(3,new java.sql.Date(t.getCreateTime().getTime()));
			ps.setInt(4,t.getIsDelete());
			ps.setString(5,t.getRemark());
			ps.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			
		}
	}

	public List<Term> getAllTem() {
		List<Term> t = new ArrayList<Term>();
		String sql = "select intId,chvName,createTime,isDelete,remark from term order by id";
		//con = util.getConnect();
		try {
			ps = con.prepareStatement(sql);
			rs = ps.executeQuery();
			while (rs.next()) {
				t.add(new Term());
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
		
		}
		return t;
	}

	@Override
	public List<Term> getAllTerm() {
		// TODO Auto-generated method stub
		return null;
	}

}



